﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MastePage/SubEmptyMaster.Master" AutoEventWireup="true" CodeBehind="BOMChangeEdit.aspx.cs" Inherits="BySoft.Web.Site.BOM.BOMChangeEdit" %>

<%@ MasterType VirtualPath="~/MastePage/SubEmptyMaster.master" %>
<%@ Register Assembly="OneSoft.Web" Namespace="OneSoft.Web.UI.WebControls" TagPrefix="asp" %>
<%@ Register Assembly="BySoft.Web.Controls" Namespace="BySoft.Web.Controls" TagPrefix="cc1" %>
<asp:Content ID="cphHeadContent" runat="server" ContentPlaceHolderID="HeadPlace">
    <script type="text/javascript">
        $(function () {
            $("#tabs").tabs({ show: function (event, ui) { iframeAutoFit(); } });
        })
        function FunAddProduct() {
            var BOMChangeID = $("#<%=lblBOMChangeID.ClientID%>").text();
            ShowTopDialog('选择BOM单', '../ComPage/QuerySProductByBOMChange.aspx?id=' + BOMChangeID, 'FillProess();', 1000, 600); return false;
        }
        function FillProess() {
            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                str = decodeURIComponent(str);
                var strs = str.split(',');
                if (undefined != strs[0]) {
                    document.getElementById("<%=hdWorkOrderNo.ClientID%>").value = strs[0];
                }
                if (undefined != strs[1]) {
                    document.getElementById("<%=txtProductID.ClientID%>").value = strs[1];
                }
                if (undefined != strs[2]) {
                    document.getElementById("<%=txtProductName.ClientID%>").value = strs[2];
                }
                if (undefined != strs[3]) {
                    document.getElementById("<%=txtUnit.ClientID%>").value = strs[3];
                }
                if (undefined != strs[4]) {
                    document.getElementById("<%=hdBOMID.ClientID%>").value = strs[4];
                }
            }

            setCookie(dialogReturn_key, "");
        }
        function CheckNumWithDotOne(txtBox) {
            if (txtBox != null && txtBox.value != "") {
                var numFormat = /(^[0-9]\d{0,9}(\.\d{0,4})?$)/;
                var text = txtBox.value;
                if (!numFormat.test(text)) {
                    txtBox.value = 0;
                }
            }
        }
        function FunAdd() {
            var strBOMID = $("#<%=hdBOMID.ClientID %>").val();
            if (strBOMID == "") {
                ShowTopAlert("提示", "请先选择BOM单！");
                return false;
            }
            ShowTopDialog('选择原料', '../ComPage/QueryMBOMChangeMaterial.aspx?id=' + strBOMID, 'FillDataView();', 1000, 600); return false;
        }
        function FillDataView() {
            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                $("#<%=btnHidden.ClientID%>").click();
            }
            setCookie(dialogReturn_key, "");
        }
    </script>
</asp:Content>
<asp:Content ID="cphContent" runat="server" ContentPlaceHolderID="EmptyMasteCPH">
    <h1 class="tit">BOM管理 >> <a href="BOMChangeList.aspx">BOM变更单>></a> 编辑</h1>
    <br />
    <div class="tableStyle2">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <table border="0" cellspacing="0" cellpadding="0" style="text-align: left; width: 100%"
                    id="tBase" runat="server">
                    <tr>
                        <th class="left2">号码</th>
                        <td class="right2">
                            <asp:Label ID="lblBOMChangeID" runat="server" CssClass="lblreadonly"></asp:Label></td>
                        <th class="left2">日期：
                        </th>
                        <td class="right2">
                            <input class="Wdate" id="cpBillDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="true" runat="server" type="text"></input>
                        </td>
                    </tr>
                    <tr>
                        <th class="left2">产品编号：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtProductID" runat="server" CssClass="lblreadonly"></asp:TextBox>
                            <asp:HiddenField ID="hdWorkOrderNo" runat="server" />
                            <asp:HiddenField ID="hdBOMID" runat="server" />
                            <span style="color: Red">*</span>
                            <asp:RequiredFieldValidator ControlToValidate="txtProductID" ID="RequiredFieldValidator2" Display="None" runat="server" ErrorMessage="请选择产品" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                            <a style="cursor: pointer;" onclick="FunAddProduct()">
                                <img src="../App_Themes/Common_CSS/images/dot_14.gif" alt="" /></a>
                        </td>
                        <th class="left2">产品名称：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtProductName" runat="server" CssClass="lblreadonly"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <th class="left2">计量单位：</th>
                        <td class="right2">
                            <asp:TextBox ID="txtUnit" runat="server" CssClass="lblreadonly"></asp:TextBox></td>
                        <th class="left2"></th>
                        <td class="right2"></td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="tableStyle">
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">用料明细</a></li>
            </ul>
            <div id="tabs-1">
                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                    <ContentTemplate>
                        <div style="width: 100%; padding-bottom: 10px">
                            <div align="right">
                                <label class="btnStylec png_bg">
                                    <asp:Button ID="btnAdd" runat="server" Text="原料" OnClientClick="FunAdd()" />
                                    <asp:Button ID="btnHidden" runat="server" CssClass="Hidden" OnClick="btnHidden_Click"/>
                                </label>
                            </div>
                        </div>
                        <div>
                            <asp:SGridView runat="server" ID="grdResult" Width="100%" ShowActionToolBar="false"
                                AutoGenerateColumns="false" AllowCascade="false" OnRowDataBound="grdResult_RowDataBound" OnRowCommand="grdResult_RowCommand">
                                <Columns>
                                    <asp:TemplateField HeaderText="BOM变更明细编号" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblBOMChangeDetailID" Text='<%#Eval("BOMChangeDetailID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="BOM明细编号" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblBOMDetailID" Text='<%#Eval("BOMDetailID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="序号">
                                        <ItemTemplate>
                                            <asp:Label ID="lblOrderNum" Text='<%#Eval("OrderNum") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="原料编号">
                                        <ItemTemplate>
                                            <asp:Label ID="lblMaterialID" runat="server" Text='<%#Eval("MaterialID") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="原料品名">
                                        <ItemTemplate>
                                            <asp:Label ID="lblMaterialName" Text='<%#Eval("MaterialName") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="规格">
                                        <ItemTemplate>
                                            <asp:Label ID="lblSpecifications" Text='<%#Eval("Specifications") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="单位">
                                        <ItemTemplate>
                                            <asp:Label ID="lblUnit" Text='<%#Eval("Unit") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="变更类别">
                                        <ItemTemplate>
                                            <asp:DropDownList ID="ddlChangeType" runat="server"></asp:DropDownList>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="数量">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtNums" Text='<%#Eval("Nums") %>' runat="server" onkeyup="CheckNumWithDotOne(this);"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="备注">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtRemark" Text='<%#Eval("Remark") %>' runat="server"></asp:TextBox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <HeaderStyle Width="35px" />
                                        <HeaderTemplate>
                                            删除
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:ImageButton ImageUrl="../App_Themes/Common_CSS/images/delete_small.gif" runat="server"
                                                ID="ibtnDel" />
                                            <asp:Button ID="btnDel" runat="server" CssClass="Hidden" CommandArgument='<%#Eval("BOMDetailID") %>'
                                                CommandName="del" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:SGridView>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
    <div class="controlBar" align="center">
        <table cellpadding="0" cellspacing="0" style="width: 300px; margin: 0 auto;">
            <tr>
                <td colspan="4">
                    <label class="btnStyleb png_bg">
                        <asp:Button ID="btnSubmit" runat="server" Text="确定" OnClick="btnSubmit_Click"
                            class="png_bg" />
                    </label>
                    <label class="btnStylec png_bg">
                        <input type="button" id="Button2" value="返回" runat="server" onclick="window.location = 'BOMChangeList.aspx'"
                            class="png_bg" />
                    </label>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
